package com.hotel.controller;

import com.hotel.pojo.Checkin;
import com.hotel.service.CheckinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author shkstart  预订订单控制器
 * @create 2021-06-26 19:47
 */
@Controller
public class CheckController {

    @Autowired
    CheckinService checkinService;

    //跳转到入住界面
    @RequestMapping("/skip/toCheckOrder")
    public String toCheckOrder(Model model) {
        List<Checkin> list = checkinService.list(null);
        model.addAttribute("checks",list);
        return "admin/views/checkOrder";
    }

    //删除入住订单
    @RequestMapping("/deletedCheck/{id}")
    public String deletedCheck(@PathVariable("id")Integer id){
        boolean b = checkinService.removeById(id);
        System.out.println("订单删除结果为===>" + b);
        return "redirect:/skip/toCheckOrder";
    }

}
